package com.java.simple.study.jvm.gc;

import java.util.ArrayList;
import java.util.List;

/**
 * @author zhoujunlin
 * @date 2021/12/18
 * @desc 演示垃圾回收信息
 * -Xms20m -Xmx20m -Xmn10m -XX:+UseSerialGC -XX:+PrintGCDetails -verbose:gc
 **/
public class Demo7_2 {

    private static final int _512KB = 512 * 1024;
    private static final int _1MB = 1 * 1024 * 1024;
    private static final int _6MB = 6 * 1024 * 1024;
    private static final int _7MB = 7 * 1024 * 1024;
    private static final int _8MB = 8 * 1024 * 1024;

    public static void main(String[] args) {
        List<byte[]> list = new ArrayList<>();
        list.add(new byte[_8MB]);  // 大对象直接放入到老年代了
        list.add(new byte[_8MB]); //会触发Full GC（包含了触发Minor GC）可以看出没有收益且内存不足导致OOM
    }

}
